package strings

import "fmt"

// RuneCutting 按照字节限制，以字符编码的形式切割字符串
func RuneCutting(in string, byteLimit int) (arr []string) {
	runemsg := []rune(in)
	start := 0
	length := len(runemsg)
	for start < length {
		i := 0
		for i = length; i > start; i-- {
			if len(string(runemsg[start:i])) < byteLimit {
				break
			}
		}
		if i == start {
			fmt.Printf("can`t cut by limit[%d]\n", byteLimit)
			return
		}
		arr = append(arr, string(runemsg[start:i]))
		start = i
	}
	return
}
